package hsb.ruoyi.common.converter;

import javax.ws.rs.ext.ParamConverter;
import javax.ws.rs.ext.Provider;
import java.time.LocalDateTime;
import java.time.format.DateTimeParseException;

/**
 * @author 胡帅博
 * @date 2023/1/4 23:58
 */
@Provider
public class LocalDateTimeParamConverter implements ParamConverter<LocalDateTime> {
    public LocalDateTime fromString(String value){
        try {
            return LocalDateTime.parse(value);
        } catch (DateTimeParseException e) {

        }
        return null;
    }

    public String toString(LocalDateTime value){
        return value.toString();
    }
}
